class ComplexLinkedNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.sibling = None


class Task35:
    def run(self, head):
        if head is None:
            return None

        node = head
        while node is not None:
            node_copy = ComplexLinkedNode(node.val)
            node_copy.next = node.next
            node.next = node_copy
            node = node_copy.next

        node = head
        while node is not None:
            if node.sibling is not None:
                node_copy = node.next
                node_copy.sibling = node.sibling.next
            node = node.next.next

        head_copy = head.next
        node = head
        node_copy = head_copy
        while node_copy.next is not None:
            node.next = node.next.next
            node_copy.next = node_copy.next.next
            node = node.next
            node_copy = node_copy.next
        node.next = None
        node_copy.next = None

        return head_copy
